package crm.implementor;


import crm.daoInterfaces.FollowUpActionDao;
import crm.dbhandelling.Crude;
import crm.model.FollowUpAction;


public class FollowUpActionImp extends Crude implements FollowUpActionDao
{

	private String className= new FollowUpAction().getClass().getName();
	
	
	@Override
	public void add(FollowUpAction time) throws Exception
	{
		super.insert(time);
		
	}

	@Override
	public void update(FollowUpAction time) 
	{
	
		super.update(className, "enquiryCode", time.getEnquiryCode()+"", "actionId", time.getAutoActionId()+"");
		super.update(className, "stateId", time.getStateId()+"", "actionId", time.getAutoActionId()+"");
		super.update(className, "attendedId", time.getAttendedId()+"", "actionId", time.getAutoActionId()+"");
		super.update(className, "comments", time.getComments(), "actionId", time.getAutoActionId()+"");
		super.update(className, "followupDate", time.getFollowUpDate()+"", "actionId", time.getAutoActionId()+"");
		super.update(className, "followUpTime", time.getFollowUpTime()+"", "actionId", time.getAutoActionId()+"");
		super.update(className, "ActionName", time.getActionName(), "actionId", time.getAutoActionId()+"");
		super.update(className, "followUpStatus", time.getFollowUpStatus()+"", "actionId", time.getAutoActionId()+"");
		
	}

	@Override
	public void delete(FollowUpAction time) 
	{
		super.delete(className, "actionId", time.getAutoActionId()+"");
	}

	

	@Override
	public FollowUpAction[] retrieveAll() throws Exception 
	{
		Object[] att=super.retreiveAll(className);
		FollowUpAction[] s=new FollowUpAction[att.length];
		for(int i=0;i<s.length;i++)
				s[i]=(FollowUpAction) att[i];
		return s;
		
	}

	@Override
	public FollowUpAction retrieve( String conditionField,String conditionValue) throws Exception {
		FollowUpAction f=(FollowUpAction) super.retreive(className, conditionField, conditionValue);
		return f;
	}

	@Override
	public FollowUpAction[] retrieveArray(
			String conditionField, String conditionValue) throws Exception 
	{
		Object[] att=super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		FollowUpAction[] s=new FollowUpAction[att.length];
		for(int i=0;i<s.length;i++)
				s[i]=(FollowUpAction) att[i];
		return s;
		
	}

	public int getAutoGenratedKey()
	  {
		 int key=super.getAutoGenratedKey(className,"autoactionId") ;
		 return key;
	  }
}
